package com.client.controller;


import com.client.common.R;
import com.client.dto.GoodsAndLanguageDto;
import com.client.pojo.FlowerGoods;
import com.client.service.FlowerGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 晚云
 * @since 2023-09-12
 */
@CrossOrigin
@RestController
@RequestMapping("/flower-goods")
public class FlowerGoodsController {

    @Autowired
    private FlowerGoodsService flowerGoodsService;

    /**
     * 查询首页鲜花
     */
    @GetMapping("/home_flower/{typeId}")
    public R home_flower(@PathVariable("typeId") Integer typeId){
        List<FlowerGoods> list = flowerGoodsService.goods_list(typeId);
        return R.success(list);
    }

    /**
     * 搜索查询，根据名字查询
     * @param search
     * @return
     */
    @GetMapping("/home_search/{search_flower}")
    public R search(@PathVariable("search_flower") String search){
        List<FlowerGoods> list = flowerGoodsService.search_like(search);
        return R.success(list);
    }

    /**
     * 查询商品详细页
     * @param goodId
     * @return
     */
    @GetMapping("/details_id/{goodId}")
    public R detailsById(@PathVariable("goodId") String goodId){
        GoodsAndLanguageDto dto = flowerGoodsService.selectOne(goodId);
        return R.success(dto);
    }
}

